# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年03月20日
"""
import openpyxl

myBook=openpyxl.load_workbook('各省简称表.xlsx')
mySheet=myBook.active
myNewBook=openpyxl.Workbook()
myNewSheet=myNewBook.active
myNewSheet.title='各省简称表'
myNewSheet.append(['简称','省份'])
myRows=list(mySheet.values)[1:]
myDict={}
for myRow in myRows:
	if myRow[0] in myDict.keys():
		myDict[myRow[0]]+=myRow[1]
	else:
		myDict[myRow[0]]=myRow[1]
myDictSwap={myValue:myKey for myKey,myValue in myDict.items()}
for myKey,myValue in myDictSwap.items():
	myNewSheet.append([myKey,myValue])
myNewBook.save('结果表-各省简称.xlsx')
